//This version uses Global RegAllocation method to perform Reg Allocation.
#include "crossbit/ExecutionEngine.h"

#include "crossbit/ELFMemoryImage.h"
#include "crossbit/SimpleTCache.h"
#include "crossbit/GlobalRegAllocator.h"
#include "arch/mips/MIPSInterpreter.h"
#include "arch/mips/MIPSProcessorState.h"
#include "arch/mips/MIPSVBasicBlockBuilder.h"
#include "arch/mips/MIPSSyscallHandler.h"
#include "arch/x86/X86Translator.h"
#include "arch/x86/X86TraceManager.h"
#include "arch/x86/X86.h"

#define TCACHE_SIZE	1024*1024*10

extern char** environ;

using namespace crossbit;

int main(int argc, char *argv[])
{
				MemoryManager*	mm = MemoryManager::getInstance();
				SimpleTCache	tcache( TCACHE_SIZE, mm );

				ELFMemoryImage 	img( (XTPStr)argv[1], (XTUint32)(argc-1), (XTPStr*)&argv[1], (XTPStr*)environ );	
				MIPSProcessorState ps;
				MIPSInterpreter interp( &ps );
				MIPSVBasicBlockBuilder builder;
				GlobalRegAllocator alloc( 8, X86::movwMemToReg, X86::movwRegToMem, X86::movwRegToReg);
				X86Translator	tr( &ps, &alloc );
				X86TraceManager trace( mm );
				MIPSSyscallHandler sh(&ps, &img);

				ExecutionEngine ee( &img, mm, &trace, &interp, &builder, &tcache, &tr, &sh );
				ee.run();
	
				return 0;
}

